//
//  FinishStockViewController.m
//  DA_V
//
//  Created by 中亿世联前台 on 15/5/6.
//  Copyright (c) 2015年 zhouhai. All rights reserved.
//

#import "FinishStockViewController.h"
#import "ConfirmShopingListViewController.h"
#import "ShoppingListAddressView.h"
#import "ShoppingImageView.h"
#import "ShoppingImageScrollView.h"
#import "PaymentValuatioTableViewCell.h"
#import "UIViewAdditions.h"
#import "AllPraceViw.h"
#import "InterFace.h"
#import "AddressView.h"
#import "InformationButton.h"
#import "InfoViewController.h"
#import "CarModel.h"
@interface FinishStockViewController ()
@property (nonatomic, strong) AddressView *addressView;
@property (nonatomic, strong) ShoppingImageScrollView *shoppingScrollView;
@property (nonatomic, strong) UIScrollView *scrollView;
@end

@implementation FinishStockViewController
- (instancetype)init{
    self = [super init];
    if (self) {
        //初始化接收数组
         self.carModelArray = [NSMutableArray array];
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = LineColor;
   
    
    [self.navigationItem setHidesBackButton:YES];
    [self createBackButton];
    
    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
//    self.scrollView.backgroundColor = LineColor;
    //    if (SCREEN_HEIGHT < 568) {
    self.scrollView.contentSize = CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT*1.2);
    //    }
    [self.view addSubview:self.scrollView];
    [self creareAddressView];
}


#pragma -mmark 创建返回按钮
-(void)createBackButton{
    UIView *qview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 40)];
    
    UIButton *backBut = [UIButton buttonWithType:UIButtonTypeCustom];
    backBut.frame = CGRectMake(-25, -2, 85, 44);
    [backBut setImage:[UIImage imageNamed:@"fanhui"] forState:UIControlStateNormal];
    [backBut addTarget:self action:@selector(backClick23) forControlEvents:UIControlEventTouchUpInside];
    [qview addSubview:backBut];
    
    UILabel *title = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2-110, 5, 200, 30)];
    title.textAlignment = NSTextAlignmentCenter;
    title.font = [UIFont fontWithName:@"Helvetica-Bold" size:17];
    title.text = @"提交库存订单";
    title.textColor = [UIColor whiteColor];
    [qview addSubview:title];
    self.navigationItem.titleView = qview;
    
    InformationButton *infonmationBut = [[InformationButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-50, 0, 44, 44)];
    infonmationBut.informationNum.text = @"20";
    [infonmationBut addTarget:self action:@selector(infoClicka) forControlEvents:UIControlEventTouchUpInside];
    [infonmationBut setImage:[UIImage imageNamed:@"查看库存_03"] forState:UIControlStateNormal];
    [qview addSubview:infonmationBut];
    
}

-(void)infoClicka{
    InfoViewController *infomation =[[InfoViewController alloc] init];
    [self.navigationController pushViewController:infomation animated:YES];
}
#pragma -mark 返回按钮事件
- (void)backClick23{
     [[NSNotificationCenter defaultCenter] postNotificationName:@"CarNumberChange"object:nil];
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden=NO;
}
#pragma -mark 添加地址View

- (void)creareAddressView{
    
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 300)];
 
    self.addressView = (AddressView *)[[[NSBundle mainBundle] loadNibNamed:@"AddressXib" owner:self options:nil] objectAtIndex:0];
    self.addressView.listNum.text = [NSString stringWithFormat:@"订单号:%@",self.masterOrderId];
    self.addressView.listTime.text = [NSString stringWithFormat:@"下单时间:%@",self.xiaDanTime];
    
    
    NSString *name = [[NSUserDefaults standardUserDefaults] objectForKey:@"RealName"];
    NSString *phoneNum = [[NSUserDefaults standardUserDefaults] objectForKey:@"MobileNumber"];
    self.addressView.name.text = [NSString stringWithFormat:@"下单人:%@",name];//@"下单人:吴彦祖";
    self.addressView.phoneNUme.text = [NSString stringWithFormat:@"电    话:%@",phoneNum];
    self.addressView.address.hidden = YES;
    self.addressView.userInteractionEnabled = NO;
    _addressView.frame = CGRectMake(0, 0, SCREEN_WIDTH, 200);
    [view addSubview:_addressView];
    
 
    
    //创建滑动商品图片
    CGRect rect = CGRectMake(0, self.addressView.bottom-80, SCREEN_WIDTH, (SCREEN_WIDTH-50) / 3.0+40);
    self.shoppingScrollView = [ShoppingImageScrollView  soppingImageScrollViewWithFrame:rect data:self.carModelArray];
    self.shoppingScrollView.backgroundColor = [UIColor whiteColor];
    self.shoppingScrollView.contentSize = CGSizeMake(SCREEN_WIDTH*(self.carModelArray.count/3.0), 120);
    [view addSubview:self.shoppingScrollView];
    
    
    //线条
    UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(10, self.shoppingScrollView.bottom+12, SCREEN_WIDTH-20, 1)];
    lineView.backgroundColor = LineColor;
    [view addSubview:lineView];
    //线条
    UIView *lineView2 = [[UIView alloc]initWithFrame:CGRectMake(10, self.shoppingScrollView.top-1, SCREEN_WIDTH-20, 1)];
    lineView2.backgroundColor = LineColor;
    [view addSubview:lineView2];
    
    //总金额view
    AllPraceViw *allPraceView = (AllPraceViw *)[[[NSBundle mainBundle] loadNibNamed:@"Shopping_Cart_Xib" owner:self options:nil] objectAtIndex:8];
    allPraceView.allPrace.text = [NSString stringWithFormat:@"%@",self.carModel.MarketPriceAmount];
    allPraceView.merchantPrace.text = [NSString stringWithFormat:@"%@",self.carModel.DiscountPriceAmount];
    allPraceView.frame = CGRectMake(0, lineView.bottom-11, SCREEN_WIDTH, 50);
    [view addSubview:allPraceView];
    [self.scrollView addSubview:view];
    

    UIImageView *tijaoImage = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/3.0-30, view.bottom+35, 20, 20)];
    tijaoImage.image = [UIImage imageNamed:@"订单完成_03"];
    [self.scrollView addSubview:tijaoImage];
    
    UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(tijaoImage.right, view.bottom+25, SCREEN_WIDTH/3.0-40+60, 40)];
    
    title.text = @"您的库存订单已提交";
    title.font = [UIFont fontWithName:nil size:13];
    [self.scrollView addSubview:title];
    
    UIButton *backBut = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/3.0-30, tijaoImage.bottom+10, SCREEN_WIDTH/3.0+50, 40)];
    [backBut addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
    [backBut setBackgroundImage:[UIImage imageNamed:@"订单完成_07"] forState:UIControlStateNormal];
    [self.scrollView addSubview:backBut];
    
//    //去支付
//    UIButton *goZhiFu = [[UIButton alloc] initWithFrame:CGRectMake(10, title.bottom+20, (SCREEN_WIDTH-20)/2.0, 40)];
//    [goZhiFu setBackgroundImage:[UIImage imageNamed:@"支付在线支付-客户_09"] forState:UIControlStateNormal];
//    [goZhiFu addTarget:self action:@selector(goZhiFu) forControlEvents:UIControlEventTouchUpInside];
//    [view addSubview:goZhiFu];
//    
//    
//    //返回选购
//    UIButton *backBut = [[UIButton alloc] initWithFrame:CGRectMake(goZhiFu.right+1, title.bottom+20, (SCREEN_WIDTH-20)/2.0, 40)];
//    [backBut addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
//    [backBut setBackgroundImage:[UIImage imageNamed:@"订单完成_07"] forState:UIControlStateNormal];
//    [self.scrollView addSubview:backBut];
    
    
}

#pragma -mark 去支付
-(void)goZhiFu{
    
}


-(void)backClick{
    [self.navigationController popViewControllerAnimated:YES];
}


@end
